package ddd7;

import java.util.*;

public class DouDiZhu {
    public static void main(String[] args) {
        Map<Integer,String> poker=new HashMap<>();
        String[] colors={"♠", "♥", "♣", "♦"};
        String[] numbers={"2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"};
        int index = 0;
        poker.put(index++,"大王");
        poker.put(index++,"小王");
        for(String number:numbers){
            for(String color:colors){
                poker.put(index++,color+number);
            }
        }


        ArrayList<Integer> pokerIndex = new ArrayList<>();
        for(int i=0;i<54;i++){
            pokerIndex.add(i);
        }
        System.out.println(poker);
        //洗牌
        Collections.shuffle(pokerIndex);



        System.out.println(poker);
        Player p1=new Player();
        p1.setName("老王");
        Player p2=new Player();
        p2.setName("老李");
        Player p3=new Player();
        p3.setName("老六");
        List<Integer> diPai=new ArrayList<>();
        for(int i=0;i<poker.size();i++){
            int card = pokerIndex.get(i);
            if(i>=51){
                diPai.add(card);
            }else if(i%3==0){
                p1.getPoker().add(card);
            }else if(i%3==1){
                p2.getPoker().add(card);
            }
            else if(i%3==2){
                p3.getPoker().add(card);
            }
        }
//        System.out.println(p1.getName()+":"+p1.getPoker());
//        System.out.println(p2.getName()+":"+p2.getPoker());
//        System.out.println(p3.getName()+":"+p3.getPoker());

        printCards(p1.getName(),p1.getPoker(),poker);
        printCards(p2.getName(),p2.getPoker(),poker);
        printCards(p3.getName(),p3.getPoker(),poker);
    }
    private static void printCards(String name, List<Integer> list, Map<Integer, String> map) {
        Collections.sort(list);
        System.out.print(name + ": ");
        for (int key : list) {
            System.out.print(map.get(key) + " ");
        }
        System.out.println();
    }
}
